//
//  YSShouzhimingxiViewController.m
//  YSZC
//
//  Created by 张斌 on 16/5/3.
//  Copyright © 2016年 YueShiKeJi. All rights reserved.
//

#import "YSShouzhimingxiViewController.h"

#import "BINbutton.h"
#import "UIView+CZFrame.h"

@interface YSShouzhimingxiViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableview;
@property (nonatomic,strong)UIView* selectview;

@end

@implementation YSShouzhimingxiViewController

- (UIView *)selectview{
    if (_selectview == nil) {
        _selectview = [[UIView alloc] initWithFrame:CGRectMake(0, -116, [UIScreen mainScreen].bounds.size.width,180)];
        _selectview.backgroundColor = [UIColor whiteColor];
    }
    return _selectview;
}

// 设置按钮的分状态背景图片
- (void)setbackimageWith:(NSString*)imagename and:(UIButton*)btn{
    [btn setBackgroundImage:[UIImage imageNamed:imagename] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@gou",imagename]] forState:UIControlStateSelected];
//    [btn setImage:[UIImage imageNamed:imagename] forState:UIControlStateNormal];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
   
    [self.view addSubview:self.selectview];
    

    self.tableview.delegate = self;
    self.tableview.dataSource = self;
    
    
    UIButton* btn1 = [[UIButton alloc] initWithFrame:CGRectMake(15, 0, _selectview.w-30, _selectview.h/3)];
    [btn1 addTarget:self action:@selector(btn1click:) forControlEvents:   UIControlEventTouchUpInside];
    
    
    UIButton* btn2 = [[UIButton alloc] initWithFrame:CGRectMake(15, _selectview.h/3, _selectview.w-30, _selectview.h/3)];
    [btn2 addTarget:self action:@selector(btn2click:) forControlEvents:   UIControlEventTouchUpInside];
    
    UIButton* btn3 = [[UIButton alloc] initWithFrame:CGRectMake(15, _selectview.h/3*2, _selectview.w-30, _selectview.h/3)];
    [btn3 addTarget:self action:@selector(btn3click:) forControlEvents:   UIControlEventTouchUpInside];
    
    btn1.highlighted = NO;
    btn2.highlighted = NO;
    btn3.highlighted = NO;
    
    [self setbackimageWith:@"quanbu" and:btn1];
    [self setbackimageWith:@"shouru" and:btn2];
    [self setbackimageWith:@"zhichu" and:btn3];
    
    [_selectview addSubview:btn1];
    [_selectview addSubview:btn2];
    [_selectview addSubview:btn3];
    
}

- (IBAction)allclick:(BINbutton *)sender {
    //  动画的方式 小三角旋转
    if (self.selectview.y == -116) {
        [UIView animateWithDuration:0.5 animations:^{
            sender.imageView.transform=CGAffineTransformRotate(sender.imageView.transform, M_PI);
            
            self.selectview.y = 64;
           
        }];
    }else {
        [UIView animateWithDuration:0.5 animations:^{
            sender.imageView.transform=CGAffineTransformRotate(sender.imageView.transform, M_PI);
            
            self.selectview.y = -116;
        }];
        
    }
    
    
}

- (void)btn1click:(UIButton*)sender{
    sender.selected = !sender.selected;
}
- (void)btn2click:(UIButton*)sender{
    sender.selected = !sender.selected;
    
}
- (void)btn3click:(UIButton*)sender{
    sender.selected = !sender.selected;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 8;
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"ShouzhimingxiCell"];
    return cell;
}



@end
